//
//  XXJTabBarController.m
//  不得姐
//
//  Created by 许小军 on 16/9/1.
//  Copyright © 2016年 wyzc. All rights reserved.
//

#import "XXJTabBarController.h"
#import "XXJEssenceViewController.h"
#import "XXJFTViewController.h"
#import "XXJMeViewController.h"
#import "XXJNewViewController.h"
#import "XXJPublishViewController.h"
#import "XXJTarBar.h"
#import "XXJNavigationController.h"
@interface XXJTabBarController ()

@end

@implementation XXJTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    [self setChildrenView];
    [self setTabTitle];
    [self setChangeTabBar];
    
}
+(void)load
{
    UITabBarItem * item=[UITabBarItem appearanceWhenContainedIn:self, nil];
    NSMutableDictionary * dict=[NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName]=[UIColor blackColor];
    [item setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    NSMutableDictionary * dict1=[NSMutableDictionary dictionary];
    dict1[NSFontAttributeName]=[UIFont systemFontOfSize:13];
    [item setTitleTextAttributes:dict1 forState:UIControlStateNormal];
}

-(void)setChangeTabBar
{
    XXJTarBar * tabBar=[[XXJTarBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];
}

-(void)setChildrenView
{
    XXJEssenceViewController * essence=[[XXJEssenceViewController alloc]init];
    XXJNavigationController * navEss=[[XXJNavigationController alloc]initWithRootViewController:essence];
    [self addChildViewController:navEss];
    
    
    XXJNewViewController * new=[[XXJNewViewController alloc]init];
    XXJNavigationController * navNew=[[XXJNavigationController alloc]initWithRootViewController:new];
    [self addChildViewController:navNew];
    
    
    
    //XXJPublishViewController * publish=[[XXJPublishViewController alloc]init];
    //UINavigationController * navPub=[[UINavigationController alloc]initWithRootViewController:publish];
    //[self addChildViewController:navPub];
    
    
    XXJFTViewController * ft=[[XXJFTViewController alloc]init];
    XXJNavigationController * navFt=[[XXJNavigationController alloc]initWithRootViewController:ft];
    [self addChildViewController:navFt];
    
    
    UIStoryboard * storybord=[UIStoryboard storyboardWithName:NSStringFromClass([XXJMeViewController class]) bundle:nil];
    XXJMeViewController * me=[storybord instantiateInitialViewController];
    XXJNavigationController * navMe=[[XXJNavigationController alloc]initWithRootViewController:me];
    [self addChildViewController:navMe];
}

-(void)setTabTitle
{
    XXJNavigationController * navEss=self.childViewControllers[0];
    navEss.tabBarItem.title=@"精华";
    navEss.tabBarItem.image=[UIImage imageNamed:@"tabBar_essence_icon"];
    navEss.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_essence_click_icon"];
    
    XXJNavigationController * navNew=self.childViewControllers[1];
    navNew.tabBarItem.title=@"新帖";
    navNew.tabBarItem.image=[UIImage imageNamed:@"tabBar_new_icon"];
    navNew.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_new_click_icon"];
    
    //UINavigationController * navPub=self.childViewControllers[2];
    //navPub.tabBarItem.title=@"发布";
   // navPub.tabBarItem.image=[UIImage imageNamed:@"tabBar_publish_icon"];
    //navPub.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_publish_click_icon"];
    
    XXJNavigationController * navFt=self.childViewControllers[2];
    navFt.tabBarItem.title=@"关注";
    navFt.tabBarItem.image=[UIImage imageNamed:@"tabBar_friendTrends_icon"];
    navFt.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_friendTrends_click_icon"];
    
    XXJNavigationController * navMe=self.childViewControllers[3];
    navMe.tabBarItem.title=@"我的";
    navMe.tabBarItem.image=[UIImage imageNamed:@"tabBar_me_icon"];
    navMe.tabBarItem.selectedImage=[UIImage imageNamed:@"tabBar_me_click_icon"];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
